package com.fjb.controller.user;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fjb.common.entity.HttpCode;
import com.fjb.common.entity.JsonResult;
import com.fjb.controller.base.BaseController;
import com.fjb.dto.LoginUserInfo;
import com.fjb.service.user.SysUserPraiseService;

/**
 * <p>
 * 用户超赞 前端控制器
 * </p>
 *
 * @author hemiao
 * @since 2020-02-24
 */
@Controller
@RequestMapping("/userPraise")
public class SysUserPraiseController extends BaseController{
	
	@Autowired
	private SysUserPraiseService sysUserPraiseService;
	
	/**
	 * @Description:添加超赞
	 * @param request
	 * @param productId
	 * @return
	 * JsonResult<Boolean>
	 * @exception:
	 * @author: hemiao
	 * @time:2020年2月24日 下午7:21:00
	 */
	@RequestMapping(value="/addInfo")
	@ResponseBody
	public JsonResult<Boolean> addInfo(HttpServletRequest request,Integer productId){
		HttpCode httpCode = HttpCode.PARAM_VERIFICATION;
		if(productId==null) {
			return new JsonResult<Boolean>(null, httpCode);
		}
		LoginUserInfo userInfo = getBaseWxTokenId(request);
		return sysUserPraiseService.addInfo(userInfo, productId);
	}
	
	
	/**
	 * @Description:删除超赞
	 * @param request
	 * @param productId
	 * @return
	 * JsonResult<Boolean>
	 * @exception:
	 * @author: hemiao
	 * @time:2020年2月24日 下午7:21:14
	 */
	@RequestMapping(value="/deleteInfo")
	@ResponseBody
	public JsonResult<Boolean> deleteInfo(HttpServletRequest request,Integer productId){
		HttpCode httpCode = HttpCode.PARAM_VERIFICATION;
		if(productId==null) {
			return new JsonResult<Boolean>(null, httpCode);
		}
		LoginUserInfo userInfo = getBaseWxTokenId(request);
		Integer userId = userInfo.getUserId();
		return sysUserPraiseService.deleteInfo(productId, userId);
	}
	
}
